package com.jihui.jihuipicturebackend.exception;

/**
 * @author jihui
 * @date 2024/12/24 22:51
 */
public class ThrowUtils {

    /**
     * @Description: 自定义抛出异常方法
     */

    public static void throwIf(boolean condition, RuntimeException runtimeException){
        if(condition){
            throw runtimeException;
        }
    }

    /**
     * @Description: 自定义抛出异常方法
     */

    public static void throwIf(boolean condition, ErrorCode errorCode){
        throwIf(condition, new BusinessException(errorCode));
    }

    /**
     * @Description: 自定义抛出异常方法
     */

    public static void throwIf(boolean condition, ErrorCode errorCode,String message){
        throwIf(condition, new BusinessException(errorCode,message));
    }

}
